/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelo.DAL;

/**
 *
 * @author Nenita
 */

import java.util.Map;
import java.util.HashMap;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.JasperRunManager;

public class InformeRiesgos2_DAO {

    public InformeRiesgos2_DAO() {
    }

    public byte[] generarInforme (Map parametros) {
        ConexionBD conexion = new ConexionBD();
        byte[] pdf = null;
        String filename = "/Modulo3/informeRiesgos_subreport1.jasper";
        JasperReport masterReport = null;

        try
        {
            masterReport = (JasperReport) JRLoader.loadObject(getClass().getResource(filename));
            pdf = JasperRunManager.runReportToPdf(masterReport,parametros,conexion.session);
        }
        catch (JRException e)
        {
           e.printStackTrace();
        }

        if (conexion.session !=null)
            conexion.cerrarConexion();

        return pdf;
    }
}
